package com.codefish.codefish_blog.task;

import com.codefish.codefish_blog.redis.RedisArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * redis相关定时任务
 *
 * @author codefish
 * @version 1.0
 * @date 2022/04/15 下午 08:51
 */
@Component
public class RedisTask {
    @Autowired
    RedisArticleService redisArticleService;

    /**
     * 将redis中的文章访问量同步至数据库
     * 任务执行方式:周期,60s
     */
    @Scheduled(fixedRate = 60 * 1000)
    private void synArticleWatchedDataToDB() {
        redisArticleService.synToDB();
    }
}
